var _page = $('.page');


bottlecms.layuiuploadfile({
    elem:".uppicbtn",
    filedir:"album",
    success:function(pic){
        bottlecms.post("/m/ajax/center/photo", {
            photo: pic
        }, function(data) {
            if (data.success == true) {
                var obj=eval("("+data.obj+")");
                $(_page).find(".photobox .addbtn").before('<li><img src="' + pic + '"><i class="del" data-id="' + obj.id + '">×</i></li>')
                bottlecms.toast(data.msg);
            } else {
                bottlecms.toast(data.msg);
            }
        });
    }
});

// 删除相册图片
$(_page).on('click', '.photobox li .del', function() {
    var _this = this;
    var id = $(this).attr('data-id');
    bottlecms.confirm("确定要删除吗？", function() {
        bottlecms.delete("/m/ajax/center/photo", {
            id: id
        }, function(data) {
            if (data.success == true) {
                $(_this).parent().remove();
                bottlecms.toast(data.msg);
            } else {
                bottlecms.toast(data.msg);
            }
        });

    })
})